//
//  EditorTableViewCell.m
//  MarianasTrench
//
//  Created by 付建国 on 16/3/19.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "EditorTableViewCell.h"

@interface EditorTableViewCell ()

@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *titleL;
@property (nonatomic, strong) UILabel *degistL;
@property (nonatomic, strong) UILabel *numberL;

@end

@implementation EditorTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}
- (void)create{
    self.imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageV];
    
    self.titleL = [[UILabel alloc] init];
    [self.contentView addSubview:_titleL];
    
    self.degistL = [[UILabel alloc] init];
    [self.contentView addSubview:_degistL];
    
    self.numberL = [[UILabel alloc] init];
    [self.contentView addSubview:_numberL];
}
// 重写setter方法
- (void)setModel:(ListModel *)model{
    _model = model;
    [self fuzhi];
}
- (void)fuzhi{
    if (_model.albumCoverUrl290 != nil) {
        
//        [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.albumCoverUrl290]];
        dispatch_async(dispatch_get_main_queue(), ^{
            
            [self.imageV HANDLEIMAGE(_model.albumCoverUrl290)];
        });

    }else{

//    [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.coverSmall]];
        dispatch_async(dispatch_get_main_queue(), ^{
            
            [self.imageV HANDLEIMAGE(_model.coverSmall)];
        });
    }
    self.titleL.text = _model.title;
    if (!(_model.intro == nil)) {
        
        self.degistL.text = _model.intro;
    }else{
        self.degistL.text = _model.subtitle;
    }
    self.degistL.textColor = [UIColor grayColor];
    self.degistL.font = [UIFont systemFontOfSize:14];
    
    
    if (!(_model.tracksCounts == nil)) {
        
        NSString *str = [NSString stringWithFormat:@"集数/首数 : %@", _model.tracksCounts];
        self.numberL.text = str;
    }else{
        NSString *str = [NSString stringWithFormat:@"集数/首数 : %@", _model.footnote];
        self.numberL.text = str;
    }
    self.numberL.textColor = [UIColor grayColor];
    self.numberL.font = [UIFont systemFontOfSize:12];
}
// 布局
- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.imageV.frame = CGRectMake(10, 5, self.contentView.frame.size.height - 10, self.contentView.frame.size.height - 10);
    
    self.titleL.frame = CGRectMake(self.contentView.frame.size.height + 5, 5, self.contentView.frame.size.width - self.contentView.frame.size.height, 20);
    
    self.degistL.frame = CGRectMake(self.contentView.frame.size.height + 5, 30, self.contentView.frame.size.width - self.contentView.frame.size.height, 20);
    
    self.numberL.frame = CGRectMake(self.contentView.frame.size.height + 5, 55, self.contentView.frame.size.width - self.contentView.frame.size.height, 20);
    
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
